#ifndef __IMAGEMANAGEROPENIMAGE_H__
#define __IMAGEMANAGEROPENIMAGE_H__

#ifdef _MSC_VER
#pragma warning(disable: 4819)
#endif

#include "Image.h"
#include "ImageManager.h"
#include "FreeImage.h"
#include "ImageCodec.h"

namespace RayFrame
{
  class ImageCodecFreeImage: public Singleton<ImageCodecFreeImage>, public ImageCodec
  {
  private:
    virtual bool InitLibrary();
    virtual bool DestroyLibrary();

  public:
    DLL_DECLARE ImageCodecFreeImage();
    DLL_DECLARE virtual ~ImageCodecFreeImage();
    DLL_DECLARE virtual Image* LoadFromMemory(unsigned width, unsigned height, 
      unsigned bpp);
    DLL_DECLARE virtual Image* LoadFromFile(STRING filename);
    DLL_DECLARE virtual bool SaveToFile(Image* image, STRING filename, ImageFileFormat fif);

    DECL_SINGLETON_DLL(ImageCodecFreeImage);

    DLL_DECLARE static FREE_IMAGE_FORMAT GetFreeImageFileFormat(ImageFileFormat iff)
    {
      return static_cast<FREE_IMAGE_FORMAT>(iff);
    };
  };

}
#endif /* _IMAGEMANAGEROPENIMAGE_H_ */
